home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / Libraries / WASTE 1.1a4 / WASTE Headers / Pascal Interfaces / WASTE.p < prev   
Encoding:
Text File  |  1994-11-12  |  12.1 KB  |  364 lines  |  [TEXT/PJMM]

  1. unit WASTE;
  2.  
  3. { Pascal interface to the WASTE text engine }
  4.  
  5. { version 1.1a4 (November 1994) }
  6.  
  7. { Copyright © 1993-1994 Merzwaren }
  8. { All Rights Reserved }
  9.  
  10. interface
  11.     uses
  12.         Drag, LongCoords;
  13.  
  14.     const
  15.  
  16. { result codes }
  17.  
  18.         weCantUndoErr = -9479;                            { undo buffer is clear }
  19.         weUnknownObjectTypeErr = -9478;            { specified object type is not registered }
  20.         weObjectNotFoundErr = -9477;                    { no object found at specified offset }
  21.  
  22. { alignment styles }
  23.  
  24.         weFlushLeft = -2;                        { flush left }
  25.         weFlushRight = -1;                    { flush right }
  26.         weFlushDefault = 0;                    { flush according to system direction }
  27.         weCenter = 1;                            { centered }
  28.         weJustify = 2;                            { fully justified }
  29.  
  30. { values for the mode parameter in WESetStyle and WEContinuousStyle }
  31.  
  32.         weDoFont = $0001;                    { set font family number }
  33.         weDoFace = $0002;                    { turn on the styles specified in tsFace }
  34.         weDoSize = $0004;                    { set type size }
  35.         weDoColor = $0008;                    { set color }
  36.         weDoAll = weDoFont + weDoFace + weDoSize + weDoColor;
  37.         weDoAddSize = $0010;                { adjust type size }
  38.         weDoToggleFace = $0020;            { turn a style off if it's continuous over the selection }
  39.         weDoReplaceFace = $0040;        { replace existing styles outright }
  40.  
  41. { values for the edge parameter in WEGetOffset etc. }
  42.  
  43.         kLeadingEdge = -1;                    { point is on the leading edge of a glyph }
  44.         kTrailingEdge = 0;                        { point is on the trailing edge of a glyph }
  45.         kObjectEdge = 2;                        { point is in the middle of an embedded object }
  46.  
  47. { values for WEFeatureFlag feature parameter }
  48.  
  49.         weFAutoScroll = 0;                    { automatically scroll the selection range into view }
  50.         weFOutlineHilite = 2;                { frame selection when deactivated }
  51.         weFUndo = 6;                            { support WEUndo }
  52.         weFIntCutAndPaste = 7;            { use intelligent cut-and-paste rules }
  53.         weFDragAndDrop = 8;                { support drag-and-drop text editing }
  54.         weFInhibitRecal = 9;                    { don't recalculate line starts and don't redraw text }
  55.         weFUseTempMem = 10;            { use temporary memory for main data structures }
  56.         weFDrawOffscreen = 11;            { draw text offscreen for smoother visual results }
  57.  
  58. { values for WENew flags parameter }
  59.  
  60.         weDoAutoScroll = $0001;
  61.         weDoOutlineHilite = $0004;
  62.         weDoUndo = $0040;
  63.         weDoIntCutAndPaste = $0080;
  64.         weDoDragAndDrop = $0100;
  65.         weDoInhibitRecal = $0200;
  66.         weDoUseTempMem = $0400;
  67.         weDoDrawOffscreen = $0800;
  68.  
  69. { values for WEFeatureFlag action parameter }
  70.  
  71.         weBitClear = 0;                            { disables the specified feature }
  72.         weBitSet = 1;                            { enables the specified feature }
  73.         weBitTest = -1;                            { returns the current setting of the specified feature }
  74.  
  75. { values for WEGetInfo and WESetInfo selector parameter }
  76.  
  77.         weClickLoop = 'clik';                    { click loop callback }
  78.         weCurrentDrag = 'drag';            { drag currently being tracked from WEClick }
  79.         wePort = 'port';                            { graphics port }
  80.         weRefCon = 'refc';                        { reference constant for use by application }
  81.         weScrollProc = 'scrl';                    { scroll callback }
  82.         weText = 'text';                            { handle to the raw text }
  83.         weTranslateDragHook = 'xdrg';    { drag translation callback }
  84.         weTSMDocumentID = 'tsmd';        { Text Services Manager document ID }
  85.         weTSMPreUpdate = 'pre ';            { Text Services Manager pre-update callback }
  86.         weTSMPostUpdate = 'post';        { Text Services Manager post-update callback }
  87.  
  88. { values for WEInstallObjectHandler handlerSelector parameter }
  89.  
  90.         weNewHandler = 'new ';            { new handler }
  91.         weDisposeHandler = 'free';        { dispose handler }
  92.         weDrawHandler = 'draw';            { draw handler }
  93.         weClickHandler = 'clik';                { click handler }
  94.         weCursorHandler = 'curs';            { reserved for future use }
  95.  
  96. { action kinds }
  97.  
  98.         weAKNone = 0;                            { null action }
  99.         weAKUnspecified = 1;                { action of unspecified nature }
  100.         weAKTyping = 2;                        { some text has been typed in }
  101.         weAKCut = 3;                            { the selection range has been cut }
  102.         weAKPaste = 4;                            { something has been pasted }
  103.         weAKClear = 5;                            { the selection range has been deleted }
  104.         weAKDrag = 6;                            { drag and drop operation }
  105.         weAKSetStyle = 7;                    { some style has been applied to a text range }
  106.  
  107.     type
  108.  
  109. { WASTE data types }
  110.  
  111.         WEHandle = Handle;
  112.         WEObjectReference = Handle;
  113.         WESoupHandle = Handle;
  114.         WEActionKind = Integer;
  115.  
  116.         WERunInfo = record
  117.                 runStart: LongInt;                            { byte offset to first character of style run }
  118.                 runEnd: LongInt;                            { byte offset past last character of style run }
  119.                 runHeight: Integer;                        { line height (ascent + descent + leading) }
  120.                 runAscent: Integer;                        { font ascent }
  121.                 runStyle: TextStyle;                        { text attributes }
  122.                 runObject: WEObjectReference;        { either NIL or reference to embedded object }
  123.             end;  { WERunInfo }
  124.  
  125. { callback prototypes }
  126.  
  127. { FUNCTION MyClickLoop(hWE: WEHandle): Boolean; }
  128.         WEClickLoopProcPtr = ProcPtr;
  129.  
  130. { PROCEDURE MyScrollProc(hWE: WEHandle); }
  131.         WEScrollProcPtr = ProcPtr;
  132.  
  133. { PROCEDURE MyTSMPreUpdate(hWE: WEHandle); }
  134.         WETSMPreUpdateProcPtr = ProcPtr;
  135.  
  136. { PROCEDURE MyTSMPostUpdate(hWE: WEHandle; fixLength: LongInt; }
  137. {         inputAreaStart, inputAreaEnd:LongInt; }
  138. {        pinRangeStart, pinRangeEnd: LongInt); }
  139.         WETSMPostUpdateProcPtr = ProcPtr;
  140.  
  141. { FUNCTION MyTranslateDrag (theDrag: DragReference; theItem: ItemReference; }
  142. {         requestedType: FlavorType; putDataHere: Handle): OSErr; }
  143.         WETranslateDragProcPtr = ProcPtr;
  144.  
  145. { FUNCTION MyNewObject(VAR defaultObjectSize: Point; }
  146. {                    objectRef: WEObjectReference): OSErr; }
  147.         WENewObjectProcPtr = ProcPtr;
  148.  
  149. { FUNCTION MyDisposeObject (objectRef: WEObjectReference): OSErr; }
  150.         WEDisposeObjectProcPtr = ProcPtr;
  151.  
  152. { FUNCTION MyDrawObject (destRect: Rect; }
  153. {         objectRef: WEObjectReference): OSErr }
  154.         WEDrawObjectProcPtr = ProcPtr;
  155.  
  156. { WASTE Public Calls }
  157.  
  158. { creation and destruction }
  159.     function WENew (destRect, viewRect: LongRect;
  160.                                     flags: Integer;
  161.                                     var hWE: WEHandle): OSErr;
  162.     procedure WEDispose (hWE: WEHandle);
  163.  
  164. { getting variables }
  165.     function WEGetText (hWE: WEHandle): Handle;
  166.     function WEGetChar (offset: LongInt;
  167.                                     hWE: WEHandle): Char;
  168.     function WEGetTextLength (hWE: WEHandle): LongInt;
  169.     function WECountLines (hWE: WEHandle): LongInt;
  170.     function WEGetHeight (startLine, endLine: LongInt;
  171.                                     hWE: WEHandle): LongInt;
  172.     procedure WEGetSelection (var selStart, selEnd: LongInt;
  173.                                     hWE: WEHandle);
  174.     procedure WEGetDestRect (var destRect: LongRect;
  175.                                     hWE: WEHandle);
  176.     procedure WEGetViewRect (var viewRect: LongRect;
  177.                                     hWE: WEHandle);
  178.     function WEIsActive (hWE: WEHandle): Boolean;
  179.  
  180. { setting variables }
  181.     procedure WESetSelection (selStart, selEnd: LongInt;
  182.                                     hWE: WEHandle);
  183.     procedure WESetDestRect (destRect: LongRect;
  184.                                     hWE: WEHandle);
  185.     procedure WESetViewRect (viewRect: LongRect;
  186.                                     hWE: WEHandle);
  187.  
  188. { accessing style run information }
  189.     function WEContinuousStyle (var mode: Integer;
  190.                                     var ts: TextStyle;
  191.                                     hWE: WEHandle): Boolean;
  192.     procedure WEGetRunInfo (offset: LongInt;
  193.                                     var info: WERunInfo;
  194.                                     hWE: Handle);
  195.  
  196. { converting byte offsets to screen positions and vice versa }
  197.     function WEGetOffset (thePoint: LongPt;
  198.                                     var edge: SignedByte;
  199.                                     hWE: Handle): LongInt;
  200.     procedure WEGetPoint (offset: LongInt;
  201.                                     var thePoint: LongPt;
  202.                                     var lineHeight: Integer;
  203.                                     hWE: Handle);
  204.  
  205. { finding words and lines }
  206.     procedure WEFindWord (offset: LongInt;
  207.                                     edge: SignedByte;
  208.                                     var wordStart, wordEnd: LongInt;
  209.                                     hWE: WEHandle);
  210.     procedure WEFindLine (offset: LongInt;
  211.                                     edge: SignedByte;
  212.                                     var lineStart, lineEnd: LongInt;
  213.                                     hWE: WEHandle);
  214.  
  215. { making a copy of a text range }
  216.     function WECopyRange (rangeStart, rangeEnd: LongInt;
  217.                                     hText: Handle;
  218.                                     hStyles: StScrpHandle;
  219.                                     hSoup: WESoupHandle;
  220.                                     hWE: WEHandle): OSErr;
  221.  
  222. { getting and setting the alignment style }
  223.     function WEGetAlignment (hWE: WEHandle): SignedByte;
  224.     procedure WESetAlignment (alignment: SignedByte;
  225.                                     hWE: WEHandle);
  226.  
  227. { recalculating line breaks, drawing and scrolling }
  228.     function WECalText (hWE: WEHandle): OSErr;
  229.     procedure WEUpdate (updateRgn: RgnHandle;
  230.                                     hWE: WEHandle);
  231.     procedure WEScroll (hOffset, vOffset: LongInt;
  232.                                     hWE: WEHandle);
  233.     procedure WESelView (hWE: WEHandle);
  234.  
  235. { handling activate/deactivate events }
  236.     procedure WEActivate (hWE: WEHandle);
  237.     procedure WEDeactivate (hWE: WEHandle);
  238.  
  239. { handling key-down events }
  240.     procedure WEKey (key: Char;
  241.                                     modifiers: Integer;
  242.                                     hWE: WEHandle);
  243.  
  244. { handling mouse-down events and mouse tracking }
  245.     procedure WEClick (hitPt: Point;
  246.                                     modifiers: Integer;
  247.                                     clickTime: LongInt;
  248.                                     hWE: WEHandle);
  249.  
  250. { adjusting the cursor shape }
  251.     function WEAdjustCursor (mouseLoc: Point;
  252.                                     mouseRgn: RgnHandle;
  253.                                     hWE: WEHandle): Boolean;
  254.  
  255. { blinking the caret }
  256.     procedure WEIdle (var maxSleep: LongInt;
  257.                                     hWE: WEHandle);
  258.  
  259. { modifying the text and the styles }
  260.     function WEInsert (pText: Ptr;
  261.                                     textLength: LongInt;
  262.                                     hStyles: StScrpHandle;
  263.                                     hSoup: WESoupHandle;
  264.                                     hWE: WEHandle): OSErr;
  265.     function WEDelete (hWE: WEHandle): OSErr;
  266.     function WESetStyle (mode: Integer;
  267.                                     ts: TextStyle;
  268.                                     hWE: WEHandle): OSErr;
  269.     function WEUseText (hText: Handle;
  270.                                     hWE: WEHandle): OSErr;
  271.     function WEUseStyleScrap (hStyles: StScrpHandle;
  272.                                     hWE: WEHandle): OSErr;
  273.  
  274. { undo }
  275.     function WEUndo (hWE: WEHandle): OSErr;
  276.     procedure WEClearUndo (hWE: WEHandle);
  277.     function WEGetUndoInfo (var redoFlag: Boolean;
  278.                                     hWE: WEHandle): WEActionKind;
  279.     function WEIsTyping (hWE: WEHandle): Boolean;
  280.  
  281. { keeping track of changes }
  282.     function WEGetModCount (hWE: WEHandle): LongInt;
  283.     procedure WEResetModCount (hWE: WEHandle);
  284.  
  285. { embedded objects }
  286.     function WEInstallObjectHandler (objectType: OSType;
  287.                                     handlerSelector: OSType;
  288.                                     handler: ProcPtr): OSErr;
  289.     function WEInsertObject (objectType: OSType;
  290.                                     objectDataHandle: Handle;
  291.                                     objectSize: Point;        { (0, 0) means default size }
  292.                                     hWE: WEHandle): OSErr;
  293.     function WEGetSelectedObject (var objectRef: WEObjectReference;
  294.                                     hWE: WEHandle): OSErr;
  295.     function WEFindNextObject (offset: LongInt;
  296.                                     var objectRef: WEObjectReference;
  297.                                     hWE: WEHandle): LongInt;
  298.  
  299. { accessing embedded object attributes }
  300.     function WEGetObjectType (objectRef: WEObjectReference): OSType;
  301.     function WEGetObjectDataHandle (objectRef: WEObjectReference): Handle;
  302.     function WEGetObjectSize (objectRef: WEObjectReference): Point;
  303.     function WEGetObjectOwner (objectRef: WEObjectReference): WEHandle;
  304.     function WEGetObjectRefCon (objectRef: WEObjectReference): LongInt;
  305.     procedure WESetObjectRefCon (objectRef: WEObjectReference;
  306.                                     refCon: LongInt);
  307.  
  308. { Clipboard operations }
  309.     function WECut (hWE: WEHandle): OSErr;
  310.     function WECopy (hWE: WEHandle): OSErr;
  311.     function WEPaste (hWE: WEHandle): OSErr;
  312.     function WECanPaste: Boolean;
  313.  
  314. { Drag Manager support }
  315.     function WEGetHiliteRgn (rangeStart, rangeEnd: LongInt;
  316.                                     hWE: WEHandle): RgnHandle;
  317.     function WETrackDrag (message: DragTrackingMessage;
  318.                                     drag: DragReference;
  319.                                     hWE: WEHandle): OSErr;
  320.     function WEReceiveDrag (drag: DragReference;
  321.                                     hWE: WEHandle): OSErr;
  322.     function WECanAcceptDrag (drag: DragReference;
  323.                                     hWE: WEHandle): Boolean;
  324.     function WEDraggedToTrash (drag: DragReference): Boolean;
  325.  
  326. { Script Manager utilities }
  327.     function WECharByte (offset: LongInt;
  328.                                     hWE: WEHandle): Integer;
  329.     function WECharType (offset: LongInt;
  330.                                     hWE: WEHandle): Integer;
  331.  
  332. { Text Services Manager support }
  333.     function WEInstallTSMHandlers: OSErr;
  334.     procedure WEStopInlineSession (hWE: WEHandle);
  335.  
  336. { additional features }
  337.     function WEFeatureFlag (feature: Integer;
  338.                                     action: Integer;
  339.                                     hWE: WEHandle): Integer;
  340.     function WEGetInfo (selector: OSType;
  341.                                     info: univ Ptr;
  342.                                     hWE: WEHandle): OSErr;
  343.     function WESetInfo (selector: OSType;
  344.                                     info: univ Ptr;
  345.                                     hWE: WEHandle): OSErr;
  346.  
  347. { long coordinates utility routines }
  348.     procedure WELongPointToPoint (lp: LongPt;
  349.                                     var p: Point);
  350.     procedure WEPointToLongPoint (p: Point;
  351.                                     var lp: LongPt);
  352.     procedure WESetLongRect (var lr: LongRect;
  353.                                     left, top, right, bottom: LongInt);
  354.     procedure WELongRectToRect (lr: LongRect;
  355.                                     var r: Rect);
  356.     procedure WERectToLongRect (r: Rect;
  357.                                     var lr: LongRect);
  358.     procedure WEOffsetLongRect (var lr: LongRect;
  359.                                     hOffset, vOffset: LongInt);
  360.     function WELongPointInLongRect (lp: LongPt;
  361.                                     lr: LongRect): Boolean;
  362.  
  363. implementation
  364. end.